package com.tanhua.server.controller;

import com.tanhua.model.vo.PeachBlossomVo;
import com.tanhua.server.service.PeachBlossomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author lxb哦吼吼
 * @version 1.0
 * @description: TODO
 * @date 2021/11/17 15:01
 */

@RestController
@RequestMapping("/peachblossom")
public class PeachBlossomController {

    @Autowired
    private PeachBlossomService peachBlossomService;

    /**
     * 桃花传音 push
     *
     * @param soundFile
     * @return
     */
    @PostMapping
    public ResponseEntity pushVoice(MultipartFile soundFile) throws IOException {
        peachBlossomService.pushVoice(soundFile);
        return ResponseEntity.ok(null);
    }

    @GetMapping
    public ResponseEntity pullVoice() {
        PeachBlossomVo peachBlossomVo = peachBlossomService.pullVoice();
        return ResponseEntity.ok(peachBlossomVo);
    }
}
